  import axios, { AxiosInstance, AxiosRequestConfig } from "axios"
  import configStore from '../stores/configStore'
  import { isNull, getHttp } from "../utils/common"
  // 基础配置
  const service = axios.create({
    baseURL: "",
    timeout: 10000,
  })
 
  // 添加请求拦截器
  service.interceptors.request.use((req: any) => {
    const headers = req.headers
    headers.Authorization = configStore().token || {}
    req.baseURL = getHttp(req)
    delete headers.ip 
    return req
    }, (error) => {
    return Promise.reject(error);
  })
 
  // 添加响应拦截器
  service.interceptors.response.use((res: any) => {
    let code = res.data.errcode
    let status = res.status
    if (code === 200 || code === '200' || code || code == 0 || status == 200) {
      return res.data
    } else if (code === 601 || code === '601') {
      ElNotification({ title: '提示', message: '账号或密码错误', type: 'error' })
      return Promise.reject(res)
    } else if (code === 606 || code === '606') {
      ElNotification({ title: '提示', message: '账号或密码错误', type: 'error' })
      return Promise.reject(res)
    } else {
      ElNotification({ title: '提示', message: '请稍后再试', type: 'error' })
      return Promise.reject('error')
    }
  }, error => {
    if (error.message === 'Network Error') {
      console.log('服务器连接异常，请检查服务器！ --------------- ')
      return false
    }
    return Promise.reject(error)
  })

  export default service;

 
